/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.ce.servlet;

import com.bionic.ce.commands.*;
import com.bionic.ce.commands.bankacc.*;
import com.bionic.ce.commands.queries.*;
import com.bionic.ce.commands.systemacc.*;
import com.bionic.ce.commands.user.*;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Artem
 */
public class ControllerHelper {

    private static ControllerHelper instance = null;
    HashMap<String, ICommand> commands = new HashMap<String, ICommand>();

    public ControllerHelper() {
        commands.put("login", new CommandLogin());
        commands.put("logout", new CommandLogout());
        commands.put("goToRegister", new CommandGoToRegister());
        commands.put("registerNewUser", new CommandRegisterNewUser());
        commands.put("goToUpdate", new CommandGoToUpdate());
        commands.put("updateCurrentUser", new CommandUpdateCurrentUserInfo());
        commands.put("deleteCurrentUser", new CommandDeleteCurrentUser());
        commands.put("goToMain", new CommandGoToMain());
        commands.put("goToShowCurrentUserInfo", new CommandGoToShowCurrentUserInfo());

        commands.put("goToAddNewBankAcc", new CommandGoToAddNewBankAcc());
        commands.put("registerNewBankAcc", new CommandAddNewBankAcc());
        commands.put("selectBankAcc", new CommandSelectBankAccount());
        commands.put("goToBankAccInfo", new CommandGoToBankAccountInfo());
        commands.put("goToBankAccUpdate", new CommandGoToUpdateBankAccount());
        commands.put("updateBankAcc", new CommandUpdateBankAcc());
        commands.put("deleteBankAcc", new CommandDeleteBankAcc());

        commands.put("goToAddNewSystemAcc", new CommandGoToAddNewSystemAcc());
        commands.put("registerNewSystemAcc", new CommandAddNewSystemAcc());
        commands.put("selectSystemAcc", new CommandSelectSystemAccount());
        commands.put("goToSystemAccInfo", new CommandGoToSystemAccountInfo());
        commands.put("deleteSystemAcc", new CommandDeleteSystemAcc());
        commands.put("goToDepositBankAccInfo", new CommandDepositGoToBankAccountInfo());
        commands.put("DepositSelectedBankAccount", new CommandDepositSelectedBankAccount());
        commands.put("goToWithdrawBankAccInfo", new CommandWithdrawGoToBankAccountInfo());
        commands.put("withdrawSelectedBankAccount", new CommandWithdrawSelectedBankAccount());

        commands.put("goToQueries", new CommandGoToQueries());
        commands.put("goToActiveQueries", new CommandGoToActiveQueries());
        commands.put("goToAddQuery", new CommandGoToAddQuery());
        commands.put("addQuery", new CommandAddQuery());
        commands.put("goToMyQueries", new CommandGoToMyQueries());
        commands.put("myQueriesSelect", new CommandSelectMyQuery());
        commands.put("updateMyQuery", new CommandUpdateMyQuery());
        commands.put("deleteMyQuery", new CommandDeleteMyQuery());
        commands.put("goToMyHistory", new CommandGoToMyQueriesHistory());
        commands.put("goToSearch", new CommandGoToSearchQueries());
        commands.put("queriesSearch", new CommandQueriesSearch());
        commands.put("selectAndExchengeActiveQuery", new CommandSelectAndExchengeActiveQuery());
        
    }

    public ICommand getCommand(HttpServletRequest request) {
        ICommand command = commands.get(request.getParameter("command"));
        if (command == null) {
            command = new CommandMissing();
        }
        return command;
    }

    public static ControllerHelper getInstance() {
        if (instance == null) {
            instance = new ControllerHelper();
        }
        return instance;
    }
}
